//
//  SingleButtonCell.m
//  QuXiang
//
//  Created by Duncan on 2020/7/8.
//  Copyright © 2020 NanHuaiZi. All rights reserved.
//

#import "SingleButtonCell.h"

@implementation SingleButtonCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.clipsToBounds = YES;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor clearColor];
        [self.contentView addSubviews:[NSArray arrayWithObjects:self.singleButton, nil]];
        [self masonryLayout];
    }
    return self;
}

/// 居中小号按钮
- (void)centerSmallMasLayout {
    [self.singleButton mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.contentView);
        make.width.mas_equalTo(kFragmemtFloat(132));
        make.height.mas_equalTo(kCommonBtnHeight);
        make.bottom.equalTo(self.contentView);
    }];
}

/// 全部
- (void)allMasLayout {
    self.singleButton.cornerRadius = 0;
    [self.singleButton mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.contentView);
    }];
}

/// 会员
- (void)memberMasLayout {
    [self.singleButton mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(kFragmemtFloat(32));
        make.right.equalTo(self.contentView.mas_right).offset(-kFragmemtFloat(32));
        make.height.mas_equalTo(kCommonBtnHeight);
        make.bottom.equalTo(self.contentView);
    }];
}

#pragma mark ------- Lazy Methods -------

- (void)masonryLayout {
    [self.singleButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(kFragmemtFloat(15));
        make.right.equalTo(self.contentView.mas_right).offset(-kFragmemtFloat(15));
        make.height.mas_equalTo(kCommonBtnHeight);
        make.bottom.equalTo(self.contentView);
    }];
}

- (UIButton *)singleButton {
    if (!_singleButton) {
        _singleButton = [UIButton initWithTitle:@"确认" titleColor:[UIColor blackColor] fontSize:16];
        _singleButton.backgroundColor = k_Color_themeColor;
        _singleButton.layer.cornerRadius = kCommonBtnHeight / 2;
        _singleButton.layer.masksToBounds = YES;
    }
    return _singleButton;
}

@end
